
/* eslint comma-dangle: "off" */
const getDevConf = require('./build/webpack.dev')
const merge = require('webpack-merge')
// const CopyWebpackPlugin = require('copy-webpack-plugin')
const ScriptPlugin = require('./build/script-plugin')

const conf = {
  devServer: {
    // proxy 文档：https://github.com/chimurai/http-proxy-middleware
    proxy: [
      {
        context: ["/Mccard/ClassBrand", '/Mccard/Ajax', '/ajax/GetExamNoticeByEquipmentCode'],
        target: "http://192.168.1.110:8787",
        changeOrigin: true,
        // target: "http://192.168.1.254:9999",
      },
      {
        context: ["/online"],
        pathRewrite: {
          '^/online': ''
        },
        target: "http://ccard2.shendupeiban.com",
        changeOrigin: true,
      },
      {
        context: ["/mock"],
        pathRewrite: {
          '^/mock': ''
        },
        target: "http://" + require('./build/get-ip-adress')() + ":3002"
      },
      {
        // 直接请求 go
        context: ["/classcard/v1"],
        target: "http://192.168.1.240:8116",
        // target: "http://"+getIPAdress()+":3002"
      }]
  },
  externals: {
    'vue': 'Vue'
    // 'vue-router': 'VueRouter'
  },
  plugins: [
    // new CopyWebpackPlugin([
    //   {
    //     from: path.resolve(__dirname, 'node_modules/vue-router/dist/vue-router.min.js'),
    //     to: path.resolve(outputPath, 'js/vue-router.min.js'),
    //   }
    // ]),
    // 添加指定的 cdn 包。或者指定路径的包也行
    new ScriptPlugin([
      'http://style.shenduxuetang.com/vue/2.5.22/vue.runtime.js',
      // 配合 copy-webpack-plugin 使用
      // 'js/vue-router.min.js',
    ]),
  ]

}
// 如果webpack配置有问题，需把 require('./build/friendly-error') 去掉才能看到错误
module.exports = require('./build/friendly-error')(
  merge(
    getDevConf({
      // dirname: __dirname, // 如果是子项目则需要传
      // splitCss: true,
    }),
    conf
  )
)
